package com.aabte.design2.behavioral.command;

/**
 * @author Daniel
 * @version 1.0
 * @date 2020/5/3
 */
public class Editor {
    private String text;
    private String selection;

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    /**
     * 返回选中的文字
     */
    public String getSelection() {
        return selection;
    }

    public void setSelection(String selection) {
        this.selection = selection;
    }

    /**
     * 删除选中的文字
     */
    public void deleteSelection() {
        text = text.replace(getSelection(), "");
    }

    /**
     * 在当前位置插入剪贴板中的内容
     */
    public void replaceSelection(String clipboard) {
        text += clipboard;
    }
}
